<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        function delay(ms) {
            return new Promise((resolve, reject) => {
                setTimeout(resolve, ms)
            })
        }

        function 史记买鸡腿() {
            return delay(2000).then(() =>
                '鸡腿'
            )
        }
        function 张尧买花生() {
            return delay(5000).then(() => '花生')
        }
        function 成子睿买大葱() {
            return delay(3000).then(() => '大葱')
        }
        const begin = Date.now()
        const p = Promise.all([
            史记买鸡腿(), 张尧买花生(), 成子睿买大葱()
        ])
            .then((食材) => {
                console.log(食材, Date.now() - begin);
                return '宫保鸡丁'
            }).catch(() => {

            })
    </script>
</body>

</html>